package com.psa.agent;

import android.view.View;
import android.widget.LinearLayout;
import com.psa.element.OrderItem;
import com.psa.system.R;
import com.wxw.BaseLibrary.adapter.ViewsHelper;
import com.wxw.BaseLibrary.element.IObjectListAdapterAgent;

/**
 *
 * @author david
 * @date 2016/3/25
 */
public class OrderItemListAdapterAgent implements IObjectListAdapterAgent {
    private int iResourceID = 0;


    public OrderItemListAdapterAgent(int iResourceID) {
        this.iResourceID = iResourceID;
    }

    @Override
    public int getResourceID() {
        return iResourceID;
    }

    @Override
    public void fillContent(View view, Object o) {
        if (view != null && o instanceof OrderItem) {
            ViewsHelper helper;
            if (view.getTag() == null) {
                helper = new ViewsHelper();
                helper.getViewMap().put("text", view.findViewById(R.id.textView));
                helper.getViewMap().put("icon", view.findViewById(R.id.iv_icon));
                helper.getImageView("icon").setLayoutParams(new LinearLayout.LayoutParams(0, 0));
                view.setTag(helper);
            } else {
                helper = (ViewsHelper)view.getTag();
            }
            helper.setText("text", o.toString());
        }
    }
}
